home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / ubmalm.zip / tenners.ub < prev    next >
Text File  |  1990-08-22  |  649b  |  18 lines

  1.    10   *Tenners(N,&A(),&Leng,&F,&Oddd)
  2.    20   ' Symmetric part of the continued fraction of n^(1/2). (A half period.)
  3.    30   ' Modeled on the Pascal version.
  4.    40   ' 3 May 1990
  5.    60   local Ub%=200,U,Uu,V,Vv,Sqn
  6.    70   if N<1 then Leng=-1:return endif
  7.    80   F=1:Leng=0:Sqn=isqrt(N):A(0)=Sqn
  8.    90   U=N-Sqn*Sqn:if U=0 then return endif
  9.   110   V=Sqn
  10.   120   repeat
  11.   130   Vv=V:Uu=U:inc Leng
  12.   140   if Leng>Ub% then dec Leng:F=0:return endif
  13.   150   A(Leng)=(Sqn+V)\U:V=U*A(Leng)-V
  14.   160   U=(N-V*V)\U
  15.   170   until or{V=Vv,U=Uu}
  16.   180   if (V=Vv) then Oddd=1 else Oddd=0 endif
  17.   190   return ' End of subroutine Tenners.
  18.